package com.framework.Module.system.usera;

import com.framework.Table.Table;
import com.framerock.baselib.CDate;
import com.framerock.baselib.Jiami;
import com.framerock.baselib.Rock;


public class Tableusera extends Table {



    protected void initTable() {
        this.tablename   = "usera";
        this.tablenamesm = "单位用户";

        this.flowsetMap  = Rock.getMap(new String[]{
                "type", "系统",
                "sort", "910",
                "isxt", "2",
        });

        this.addfields("name", "varchar(50)", "", "姓名", new String[]{
                "isbt","1",
                "isss","1"
        });
        this.addfields("user", "varchar(50)", "", "用户名@@字母数字组合不能特殊符合", new String[]{
                "isonly","1",
                "isbt","1",
                "attr","onlyen",
                "isss","1"
        });
        this.addfields("deptname", "varchar(50)", "", "部门@deptid", new String[]{
                "isbt","1",
                "isss","1",
                "fieldstype","changedept"
        });
        this.addfields("deptid", "int(11)", "0", "部门ID", new String[]{
                "islu","0",
                "islb","0",
        });
        this.addfields("mobile", "varchar(20)", "", "手机号", new String[]{
                "isss", "1",
                "isbt","1",
                "isonly","1",
                "attr","mobile",
        });
        this.addfields("ranking", "varchar(50)", "", "职位", new String[]{
                "isss","1"
        });
        this.addfields("status", "tinyint(1)", "1", "状态@0|已停用|gray,1|已启用|green@启用用户", new String[]{
                "isss","1",
                "fieldstype","checkbox"
        });
        this.addfields("state", "tinyint(1)", "0", "激活@0|未激活|red,1|激活|green,2|自己退出|gray,3|离职|gray", new String[]{
                "islu","0",
                "isss","1",
                "ispx","1"
        });
        this.addfields("type", "tinyint(1)", "0", "级别@0|普通,1|管理员,2|创建者", new String[]{
                "isss","1"
        });
        this.addfields("sort", "int(11)", "0", "排序", new String[]{
                "ispx","1",
                "iseditlx","2"
        });
        this.addfields("adddt", "datetime", null, "添加时间", new String[]{
                "islu","0",
                "ispx","1",
                "islb","0"
        });
        this.addfields("cid", "int(11)", "0", "对应单位", new String[]{
                "islu","0",
                "attr","readonly"
        });
        this.addfields("uid", "int(11)", "0", "关联平台用户", new String[]{
                "islu","0",
                "islb","0"
        });
        this.addfields("workdt", "date", null, "入职日期", new String[]{
                "ispx","1",
                "isbt","1",
                "devval","{date}"
        });
        this.addfields("id", "int(11)", "0", "ID");
        this.addfields("cid", "KEY", "`cid`", "单位ID");
        this.addfields("uid", "KEY", "`uid`", "平台用户");

        this.addWhere("所有用户", "all", "1=1");
        this.addWhere("停用用户", "allty", "`status`=0");
    }

    //创建默认管理员
    protected void firstInsert() {
        int count = this.nDb.getCount(this.tablenameal, "`id`>0");
        if(count==0) {
            this.nDb.insertbo(this.tablenameal, Rock.getMap(new String[]{
                    "user", "admin",
                    "name", "管理员",
                    "deptid", "1",
                    "deptname", "信呼Java开发团队",
                    "ranking", "创建者",
                    "mobile","15800000001",
                    "type", "2",
                    "uid", "1",
                    "state", "1",
                    "cid", "1",
                    "workdt",CDate.date(),
                    "adddt", CDate.now()
            }));
        }
    }
}
